package spring.cloud.tasks.executor.task_type;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import spring.cloud.tasks.executor.task.TaskExecuteEngine;
import spring.cloud.tasks.executor.trigger.Trigger;

@Slf4j
@Setter
@Getter
public class TaskTypeBuilder {

    private TaskTypeImpl taskType;

    public TaskTypeBuilder() {
        this.taskType = new TaskTypeImpl();
    }

    public static TaskTypeBuilder newBuilder() {
        return new TaskTypeBuilder();
    }

    public TaskTypeBuilder name(String name) {
        taskType.setName(name);
        return this;
    }

    public TaskTypeBuilder triggerClass(Class<? extends Trigger> triggerClass) {
        taskType.setTriggerClass(triggerClass);
        return this;
    }

    public TaskTypeBuilder handlerClass(Class<? extends TaskExecuteEngine> handlerClass) {
        taskType.setHandlerClass(handlerClass);
        return this;
    }

    public TaskTypeBuilder cron() {
        taskType.setCron(true);
        return this;
    }

    public TaskTypeBuilder passive() {
        taskType.setPassive(true);
        return this;
    }


    public TaskTypeBuilder allowedShutdownGracefully() {
        taskType.setAllowedShutdownGracefully(true);
        return this;
    }

    public TaskType build() {
        return taskType;
    }

}
